package com.tianquan.mvc;/**
 * @author starsea
 * @date 2024-09-10 下午3:10
 */

import com.tianquan.aspect.Test;
import com.tianquan.event.Email;
import com.tianquan.event.TestPublishEvent;
import com.tianquan.exception.BaseException;
import com.tianquan.mapper.DishMapper;
import com.tianquan.spring.A;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: uploaddemo
 * @BelongsPackage: com.tianquan.controller
 * @Author: tianquan
 * @CreateTime: 2024-09-10  15:10
 * @Description: 测试
 * @Version: 1.0
 */

@RequiredArgsConstructor
@RestController
public class TestController{

    private final A a;

    private final TestPublishEvent testPublishEvent;

    private final DishMapper dishMapper;

    @GetMapping("/test1")
    @Transactional
    public String test2(A a) {
        // System.out.println(dishMapper.getById(46L));

        try {
            int c = 1 / 0;
        } catch (Exception e) {
            throw BaseException.Error(e, 500);
        }
        return dishMapper.getById(46L).toString();
    }

    @GetMapping("/test")
    @Test("11111")
    public String test() {
        System.out.println("test");
        testPublishEvent.publishEvent(new Email("123456", "eflsejflskejfo"));
        return "test";
    }

    @PostMapping("/test")
    public String test1() {
        System.out.println("test");
        return "test";
    }

}
